package com.mud.mudcommune.adapter;

import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.mud.mudcommune.R;
import com.mud.mudcommune.entry.ChiefEntry;

import java.util.List;

import butterknife.ButterKnife;

/**
 * Created by zhoujin on 2016/12/11.
 */

public class ChiefAdapter extends MyBaseAdapter {
    private List list;
    public ChiefAdapter(@NonNull List list) {
        super(list);
        this.list = list;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        ChiefEntry mChiefEntry = (ChiefEntry) list.get(position);
        ViewHolder viewHolder;
        if (view == null) {
            view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.chief_item, null);
            viewHolder = new ViewHolder(view);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.name.setText(mChiefEntry.getNickname());
        viewHolder.address.setText("四川 成都 6年设计经验");
        viewHolder.browseCount.setText(mChiefEntry.getClient() + "人浏览");
        viewHolder.sucCount.setText("226人成交");
        viewHolder.decoImg01.setImageResource(R.mipmap.test01);
        viewHolder.decoImg02.setImageResource(R.mipmap.test02);
        viewHolder.decoImg03.setImageResource(R.mipmap.test03);
        return view;
    }

    static class ViewHolder {
        SimpleDraweeView headPic;
        ImageView offer, decoImg01, decoImg02, decoImg03;
        TextView name, address, browseCount, sucCount;

        public ViewHolder(View view) {
            headPic = ButterKnife.findById(view, R.id.chief_headPic);
            offer = ButterKnife.findById(view, R.id.chief_offer);
            name = ButterKnife.findById(view, R.id.chief_name);
            address = ButterKnife.findById(view, R.id.chief_address);
            browseCount = ButterKnife.findById(view, R.id.chief_browseCount);
            sucCount = ButterKnife.findById(view, R.id.chief_sucCount);
            decoImg01 = ButterKnife.findById(view, R.id.decoration_img01);
            decoImg02 = ButterKnife.findById(view, R.id.decoration_img02);
            decoImg03 = ButterKnife.findById(view, R.id.decoration_img03);
            view.setTag(this);
        }
    }
}
